package utils;

import javafx.beans.property.SimpleObjectProperty;

public class VirtualFolder extends SimpleObjectProperty<Folder>{

    public VirtualFolder(VirtualFolder parent, String name) {
        if (parent.get() != null)
            set(parent.get().createFolder(name));

        parent.addListener((observable, oldValue, newValue) -> set(newValue.createFolder(name)));
    }

    public VirtualFolder(String folder) {
        if (folder != null)
            set(new Folder(folder));
    }

    public VirtualFolder create(String name){
        return new VirtualFolder(this, name);
    }
}
